//
//  TopicDetailTableViewCell.m
//  Zaker
//
//  Created by dllo on 16/3/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TopicDetailTableViewCell.h"

@interface TopicDetailTableViewCell ()

@property (nonatomic, retain) BaseView *bigView;

@end

@implementation TopicDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.bigView = [[BaseView alloc] init];
        [self.contentView addSubview:_bigView];
        self.bigView.layer.borderColor = [UIColor colorWithWhite:0.702 alpha:1.000].CGColor;
        self.bigView.layer.borderWidth = 1;
        
        self.askerImg = [[UIImageView alloc]init];
        [self.bigView addSubview:_askerImg];
        
        self.askerLabel = [[BaseLabel alloc]init];
        //        _askerLabel.backgroundColor = [UIColor orangeColor];
        [self.bigView addSubview:_askerLabel];
        
        self.expertImg = [[UIImageView alloc]init];
        //        _expertImg.backgroundColor = [UIColor greenColor];
        [self.bigView addSubview:_expertImg];
        
        self.expertLable = [[BaseLabel alloc]init];
        //        _expertLable.backgroundColor = [UIColor blueColor];
        [self.bigView addSubview:_expertLable];
        
        self.questionLabel = [[BaseLabel alloc]init];
        //        _questionLabel.backgroundColor = [UIColor magentaColor];
        _questionLabel.textColor = [UIColor grayColor];
        _questionLabel.numberOfLines = 0;
        [self.bigView addSubview:_questionLabel];
        
        self.answerLable = [[BaseLabel alloc]init];
        //        _answerLable.backgroundColor = [UIColor cyanColor];
        _answerLable.numberOfLines = 0;
        [self.bigView addSubview:_answerLable];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _bigView.frame = CGRectMake(10, 5, SCREEN_WIDTH - 20, self.contentView.frame.size.height - 10);
    
    _askerImg.frame = CGRectMake(5, 10, self.contentView.frame.size.width / 8, self.contentView.frame.size.width / 8);
    _askerImg.layer.cornerRadius = self.contentView.frame.size.width / 16;
    _askerImg.clipsToBounds = YES;
    
    _askerLabel.frame = CGRectMake(_askerImg.frame.origin.x + _askerImg.frame.size.width + 4, _askerImg.frame.origin.y, self.frame.size.width / 2, _askerImg.frame.size.height);
    _askerLabel.font = [UIFont systemFontOfSize:14];
    _askerLabel.textColor = [UIColor grayColor];
    //问题内容 需要自定义高度
    CGFloat questionH = [HeightAdaption heightWithText:_qcontent Size:17 Width:self.frame.size.width - _askerLabel.frame.origin.x - 40];
    
    _questionLabel.frame = CGRectMake(_askerLabel.frame.origin.x, _askerLabel.frame.origin.y + _askerLabel.frame.size.height + 5, self.frame.size.width - _askerLabel.frame.origin.x - 40, questionH);
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(_questionLabel.frame.origin.x, _questionLabel.frame.origin.y + _questionLabel.frame.size.height + 5, _questionLabel.frame.size.width, 5)];
    //    line.backgroundColor = [UIColor yellowColor];
    line.text = @".......................";
    [self.contentView addSubview:line];
    //回答
    _expertImg.frame = CGRectMake(_askerImg.frame.origin.x, line.frame.origin.y + line.frame.size.height + 5, _askerImg.frame.size.width, _askerImg.frame.size.height);
    _expertImg.layer.cornerRadius = self.contentView.frame.size.width / 16;
    _expertImg.clipsToBounds = YES;
    
    _expertLable.frame = CGRectMake(_askerLabel.frame.origin.x, _expertImg.frame.origin.y, _askerLabel.frame.size.width, _askerLabel.frame.size.height);
    CGFloat answerH = [HeightAdaption heightWithText:_acontent Size:17 Width:self.frame.size.width - _askerLabel.frame.origin.x - 40];
    _answerLable.frame = CGRectMake(_questionLabel.frame.origin.x, _expertLable.frame.origin.y + _expertLable.frame.size.height + 5, _questionLabel.frame.size.width, answerH);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
